package com.horsecoder.im.common.protocol.action.handler.support;

import com.horsecoder.im.common.protocol.action.handler.ProxyActionHandler;
import com.horsecoder.im.common.protocol.codec.GsonSingleton;
import com.horsecoder.im.common.protocol.context.chain.request.Request;
import com.horsecoder.im.common.protocol.context.chain.response.Response;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

/**
 * Author: Zhu yuhan
 * Email: zhuyuhan2333@qq.com
 * Date: 2022/3/16 1:27 下午
 **/
public class TextActionHandler extends ProxyActionHandler {
    @Override
    public ChannelFuture handle0(Channel channel, Request request, Response response) {
        return channel.writeAndFlush(new TextWebSocketFrame(GsonSingleton.gson().toJson(response)));
    }
}
